一次操作系统报错OutOfMemory Error的处理记录

查看 hs_err_pidxxxx.log内容:

#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 30408704 bytes for committing reserved memory.
# Possible reasons:
#   The system is out of physical RAM or swap space
#   In 32 bit mode, the process size limit was hit
# Possible solutions:
#   Reduce memory load on the system
#   Increase physical memory or swap space
#   Check if swap backing store is full
#   Use 64 bit Java on a 64 bit OS
#   Decrease Java heap size (-Xmx/-Xms)
#   Decrease number of Java threads
#   Decrease Java thread stack sizes (-Xss)
#   Set larger code cache with -XX:ReservedCodeCacheSize=
# This output file may be truncated or incomplete.
#
#  Out of Memory Error (os_linux.cpp:2651), pid=30569, tid=0x00007f3f8f8f8700

可能的原因

系统物理内存或虚拟内存不足
程序在压缩指针模式下运行, Java堆会阻塞本地堆的增长


第一步:找到应用的java进程的PID

ps -ef | grep java

找到进程ID为227771。

第二步:显示各进程资源占用情况。

top -p 227771 -H 


# 转换成十六进制
printf "%x" 251435

在整点找到PID 251435,转换成十六进制3d62b,再使用jstack打印出线程堆栈:

jstack 227771|grep -A 13 0x3d62b、